package com.mwy.springquartzdemo.config;

import com.mwy.springquartzdemo.job.MyJob1;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean;
import org.springframework.scheduling.quartz.SimpleTriggerFactoryBean;


public class QuartzConfig {
//    @Autowired
//    private MyJob1 myJob1;
//
//    //将jobDetail放入容器中
//    @Bean
//    public JobDetail getJobDetail(){
//        return JobBuilder.newJob(MyJob1.class)
//                .withIdentity("job1","group1")
//                .build();
//    }
//
//    //将触发器放入到容器中
//    @Bean
//    public Trigger getTrigger(){
//        return TriggerBuilder.newTrigger()
//                .withIdentity("trigger1","group1")
//                .startNow()
//                .withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(5).repeatForever())
//                .build();
//    }

//    @Bean(name="scheduler")
//    public Scheduler getScheduler(){
//        try {
//            Scheduler defaultScheduler = StdSchedulerFactory.getDefaultScheduler();
//            defaultScheduler.scheduleJob(getJobDetail(),getTrigger());
//            return defaultScheduler;
//        } catch (SchedulerException e) {
//            e.printStackTrace();
//        }
//        return null;
//    }


}
